#!/usr/bin/env python3
# coding:utf-8
import requests
import json
# server_url = 'http://0.0.0.0:8080/core/task/'
server_url = 'http://0.0.0.0:8090/core/role/'


def get_modules_by_role():
    data = {'role_id': 1}
    url = server_url + 'get_modules_by_role/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def get_buttons_by_role():
    data = {'role_id': 1}
    url = server_url + 'get_buttons_by_role/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())


def update_modules_by_role():
    data = {'role_id': 4, 'module_ids':[1,2,3,4]}
    url = server_url + 'update_modules_by_role/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def update_buttons_by_role():
    data = {'role_id': 4, 'button_ids': [1, 2, 3, 4]}
    url = server_url + 'update_buttons_by_role/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())




# get_modules_by_role()
# get_buttons_by_role()
update_modules_by_role()
# update_buttons_by_role()


if __name__ == '__main__':
    pass